package com.usian.wemedia.conreoller;

import com.usian.apis.wemedia.WmUserControllerApi;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.common.enums.AppHttpCodeEnum;
import com.usian.model.media.pojos.WmUser;
import com.usian.wemedia.service.WmUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/wemedia")
public class WmUserController implements WmUserControllerApi {
    @Autowired
    WmUserService wmUserService;

    /**
     * 袁浩 2022-6-24
     * 自媒体用户创建(新增)
     * @param wmUser
     * @return
     */
    @PostMapping("/save")
    @Override
    public ResponseResult save(@RequestBody WmUser wmUser) {
        wmUserService.save(wmUser);
        return ResponseResult.okResult(AppHttpCodeEnum.SUCCESS);
    }

    /**
     * 袁浩 2022-6-24
     * 根据姓名查自媒体用户
     * @param name
     * @return WmUser
     */
    @GetMapping("/findByName/{name}")
    @Override
    public WmUser findByName(@PathVariable("name") String name) {
        return wmUserService.findbyname(name);
    }

    @GetMapping("/findOne/{id}")
    @Override
    public WmUser findWmUserById(@PathVariable("id") Long id) {
        return wmUserService.getById(id);
    }
}
